import request from '@/utils/request'

export function http(url, data, method = "get") {
  if (method === 'get') {
    return request({
      url: `/api${url}`,
      method,
      params: data
    })
  } else {
    return request({
      url: `/api${url}`,
      method,
      data
    })
  }

}

// callback: 回调函数，在上传事件中通过callback把progressEvent对象传回调用此方法的页面
export function fileDownApi(url, data, callback) {
  return request({
      url:`/api${url}`,
      method: 'get',
      onDownloadProgress: function(progressEvent) {
          if (callback) {
            callback(progressEvent);
          }
      },
      data
  });
}

